package com.hgx.shiro.spring.service;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.session.Session;

import java.time.Instant;
import java.util.Date;

public class ShiroService {

    @RequiresRoles(value = {"admin"})
    public Date getDate() {
        Session session = SecurityUtils.getSubject().getSession();

        System.out.println("session:" + session.getAttribute("key"));

        return Date.from(Instant.now());
    }
}
